home *** CD-ROM | disk | FTP | other *** search
- // the declaration of class LINE_ELEMENT
- // Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
-
- #ifndef _LINEELEM_H_
- #define _LINEELEM_H_
-
- #include "../common/typedef.h"
- #include "../finfo.h"
- #include "../xy.h"
-
- class LINE_ELEMENT {
- bool m_select;
- XY m_ac_s;
- XY m_ac_e;
- uint m_width;
- public:
- // constructors
-
- LINE_ELEMENT()
- : m_select(false),
- m_ac_s ( ),
- m_ac_e ( ),
- m_width (0 ) {}
- LINE_ELEMENT(const LINE_ELEMENT& src)
- : m_select(src.m_select),
- m_ac_s (src.m_ac_s ),
- m_ac_e (src.m_ac_e ),
- m_width (src.m_width ) {}
- LINE_ELEMENT(const XY& ac_s, const XY& ac_e, uint width)
- : m_select(false),
- m_ac_s (ac_s ),
- m_ac_e (ac_e ),
- m_width (width) {}
-
- // operators
-
- bool operator==(const LINE_ELEMENT& r) const {
- return (ac_s() == r.ac_s())
- && (ac_e() == r.ac_e())
- && (width() == r.width());
- }
- bool operator!=(const LINE_ELEMENT& r) const {
- return !(*this == r);
- }
- bool operator<(const LINE_ELEMENT& r) const { return true; }
- bool operator>(const LINE_ELEMENT& r) const { return true; }
-
- // accessors
-
- bool is_selected() const { return m_select; }
- const XY& ac_s() const { return m_ac_s; }
- const XY& ac_e() const { return m_ac_e; }
- uint width() const { return m_width; }
-
- void select () { m_select = true; }
- void unselect() { m_select = false; }
- void set_ac_s(const XY& ac) { m_ac_s = ac; }
- void set_ac_e(const XY& ac) { m_ac_e = ac; }
- void set_width(uint width) { m_width = width; }
-
- // max and min
-
- XY get_max() const {
- return ::get_max(ac_s(), ac_e()) + width() / 2;
- }
- XY get_min() const {
- return ::get_min(ac_s(), ac_e()) - width() / 2;
- }
-
- // block-related
-
- LINE_ELEMENT shift(const XY& ac_base) const {
- LINE_ELEMENT ans = *this;
- ans.set_ac_s(ac_s() + ac_base);
- ans.set_ac_e(ac_e() + ac_base);
- return ans;
- }
-
- int is_in_block(const XY& ac1, const XY& ac2) const {
- return ac_s().is_in_box(ac1, ac2) || ac_e().is_in_box(ac1, ac2);
- }
-
- // save and load
-
- void save_200a8(FILE_NEW& fp) const;
- private:
- int unit_change_micron2kban(int micron);
- int load_170_core(const char *str);
- public:
- int load_primitive_170(const char *str);
- int load_component_170(const char *str);
- void load_200a8(const char* str);
-
- // miscellaneous
-
- int is_holizontal() const { return ac_s().y() == ac_e().y(); }
- int is_vertical() const { return ac_s().x() == ac_e().x(); }
- int is_slash() const {
- return (ac_s().x() - ac_e().x()) == (ac_s().y() - ac_e().y());
- }
- int is_backslash() const {
- return (ac_s().x() - ac_e().x()) == (ac_e().y() - ac_s().y());
- }
- int is_on_line(XYT eps, const XY& ac);
-
- void rotate_90();
- uint GetMinimumRadius() const { return width() / 2; }
- };
-
- #endif /* _LINEELEM_H_ */
-